<template>
	<view class="file-info">
		<view class="item-title">
			<text v-if='isRequired' class="is-required">*</text>
			<text>{{title}}</text>
		</view>
		<view class="file-box">
			<view class="file-item" @click="click">
				<view class="">
					<uni-icons type="paperclip" color="#589BF6"></uni-icons>
					<text>{{files}}</text>
				</view>
				<image class="delete" src="../static/image/delete.png" @click.stop="delFile" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "FileItem",
		data() {
			return {

			};
		},
		props: {
			isRequired: {
				type: Boolean,
				default: true,
			},
			title: {
				default: '标题',
				typeof: String
			},

			files: {
				default: '标题',
				typeof: String
			}
		},
		methods: {
			delFile(){
				uni.showToast({
					icon: "none",
					title: '暂无可删除的文件'
				})
			},
			click() {
				uni.showToast({
					icon: "none",
					title: '暂无可查看的文件'
				})
				return
				let token = uni.getStorageSync('jsapiToken')
				// this.$emit('click')
				console.log(token, '下载附件')
				// return;
				AlipayJSBridge.call('downloadFile', {
					jsapiToken: token,
					fileUrl: 'https://image.baidu.com/search/detail?ct=503316480&z=&tn=baiduimagedetail&ipn=d&word=%E5%8A%A8%E7%89%A9&step_word=&lid=9937687810143666893&ie=utf-8&in=&cl=2&lm=-1&st=-1&hd=undefined&latest=undefined&copyright=undefined&cs=2308777326,4174452281&os=1848747309,483433038&simid=2625231,693204599&pn=0&rn=1&di=46137345&ln=1914&fr=&fmq=1712652351538_R&ic=0&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&is=0,0&istype=2&ist=&jit=&bdtype=11&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2Fww3.sinaimg.cn%2Fmw690%2F003w6C4Mly1hoj63d2y4rj60u01hc4ah02.jpg&rpstart=0&rpnum=0&adpicid=0&nojc=undefined',
					fileName: '测试图片'
				}, (res) => {
					console.log(res, '下载测试图片')
				})
			}
		},
	}
</script>

<style lang="scss">
	.file-info {
		// display: flex;
		align-items: center;
		border-bottom: 1rpx solid #E1E0E0;
		// min-height: 76rpx;
		// justify-content: space-between;
		// white-space: nowrap;
		padding: 8rpx;
	}

	.item-title {
		font-weight: 400;
		font-size: 28rpx;
		color: #333333;
		min-width: 140rpx;
		// margin-left: 34rpx;
		margin-right: 66rpx;

	}

	.file-item {
		color: #589BF6;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.is-required {
		color: red;
		font-size: 26rpx;
	}

	.delete {
		width: 25rpx;
		height: 25rpx;
	}
</style>